﻿<!-- Copyright 2012-2017 Dmitry Kischenko

Licensed under the Apache License, Version 2.0 (the "License"); 
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 
express or implied. 
See the License for the specific language governing permissions and 
limitations under the License. -->
<Window x:Class="xFunc.Views.Converter"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:res="clr-namespace:xFunc.Resources"
        xmlns:views="clr-namespace:xFunc.Views"
        Title="{x:Static res:Resource.ConverterTitle}" Width="460" Height="286"
        ShowInTaskbar="False" ResizeMode="NoResize"
        DataContext="{Binding RelativeSource={RelativeSource Self}}">
    <Window.CommandBindings>
        <CommandBinding Command="views:Converter.CalculateCommand" Executed="CalculateCommand_Executed" CanExecute="CalculateCommand_CanExecute" />
        <CommandBinding Command="views:Converter.CopyFromCommand" Executed="CopyFromCommand_Executed" CanExecute="CopyFromCommand_CanExecute" />
        <CommandBinding Command="views:Converter.CopyToCommand" Executed="CopyToCommand_Executed" CanExecute="CopyToCommand_CanExecute" />
    </Window.CommandBindings>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Label Content="{x:Static res:Resource.ConverterTypeText}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,10,0,10" Target="{Binding ElementName=convertersComboBox}" />
        <ComboBox x:Name="convertersComboBox" VerticalAlignment="Top" Margin="116,12,10,0" DisplayMemberPath="Name" SelectedIndex="0" SelectionChanged="convertersComboBox_SelectionChanged" />

        <GroupBox Grid.Row="1" Header="{x:Static res:Resource.FromText}" Margin="10,0,10,4">
            <Grid>
                <Label Content="{x:Static res:Resource.UnitsText}" HorizontalAlignment="Left" Margin="10,0,0,0" VerticalAlignment="Top" Target="{Binding ElementName=fromComboBox}" />
                <ComboBox x:Name="fromComboBox" Margin="74,2,10,0" VerticalAlignment="Top" DisplayMemberPath="Value" SelectedIndex="0" SelectionChanged="fromToComboBox_SelectionChanged" />
                <Label Content="{x:Static res:Resource.ValueText}" HorizontalAlignment="Left" Margin="10,31,0,0" VerticalAlignment="Top" Target="{Binding ElementName=fromTextBox}" />
                <TextBox x:Name="fromTextBox" Height="23" Margin="74,35,38,0" VerticalAlignment="Top" TextChanged="fromTextBox_TextChanged" />
                <Button Height="23" Width="23" Margin="389,35,10,0" VerticalAlignment="Top" Command="views:Converter.CopyFromCommand">
                    <Image Source="..\Images\Copy_16.png" Width="16" Height="16" />
                </Button>
            </Grid>
        </GroupBox>

        <GroupBox Grid.Row="2" Header="{x:Static res:Resource.ToText}" Margin="10,0,10,4">
            <Grid>
                <Label Content="{x:Static res:Resource.UnitsText}" HorizontalAlignment="Left" Margin="10,0,0,0" VerticalAlignment="Top" Target="{Binding ElementName=toComboBox}" />
                <ComboBox x:Name="toComboBox" Margin="74,2,10,0" VerticalAlignment="Top" DisplayMemberPath="Value" SelectedIndex="0" SelectionChanged="fromToComboBox_SelectionChanged" />
                <Label Content="{x:Static res:Resource.ValueText}" HorizontalAlignment="Left" Margin="10,31,0,0" VerticalAlignment="Top" Target="{Binding ElementName=toTextBox}" />
                <TextBox x:Name="toTextBox" Height="23" Margin="74,35,38,0" VerticalAlignment="Top" TextChanged="toTextBox_TextChanged" />
                <Button Height="23" Width="23" Margin="389,35,10,0" VerticalAlignment="Top" Command="views:Converter.CopyToCommand">
                    <Image Source="..\Images\Copy_16.png" Width="16" Height="16" />
                </Button>
            </Grid>
        </GroupBox>

        <Grid Grid.Row="3" Background="#FFEFEFEF" Height="39">
            <Button Content="{x:Static res:Resource.ConverterCalculateText}" HorizontalAlignment="Right" Margin="0,10,10,8" Padding="8,0,8,0" MinWidth="75" IsDefault="True" Command="views:Converter.CalculateCommand" />
        </Grid>
    </Grid>
</Window>
